﻿using System;

namespace Basic
{
    /// <summary>
    /// IntArrayExtension
    /// </summary>
    public static class IntArrayExtension
    {
        /// <summary>
        /// 将数组转换为可读的文本串
        /// </summary>
        /// <param name="thisIntArray"></param>
        /// <returns></returns>
        public static string ToReadableString<T>(this T[] @thisIntArray)
        {
            var sb = TempStringBuilderCache.Acquire();

            sb.Append('[');
            for (int i = 0; i < thisIntArray.Length; ++i)
            {
                sb.Append(thisIntArray[i]);
                sb.Append(',');
            }
            if (sb.Length > 2)
            {
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append(']');

            return TempStringBuilderCache.GetStringAndRelease(sb);
        }
    }
}
